from marshmallow import Schema
from flask_restplus import Namespace, fields


class ParkingCollectionSchemas(object):
    def __init__(self, namespace):
        self.ns = namespace

    def ParyingCollectionIdSchemas(self):
        return self.ns.model(
            "parying_collection_id",
            {
                "id": fields.Integer(),
            },
        )

    def ParyingCollectionPostSchemas(self):
        return self.ns.model(
            "parying_collection_post",
            {
                "create_time": fields.String(),
                "update_time": fields.String(),
                "collection_type": fields.String(),
                "city": fields.String(),
                "find_park_time": fields.String(),
                "find_park_end_time": fields.String(),
                "stop_time": fields.String(),
                "end_time": fields.String(),
                "parking_type": fields.String(),
                "excavate": fields.Boolean(),
                "place_type": fields.String(),
                "time_type": fields.String(),
                "othen_type": fields.String(),
                "park_user": fields.String(),
                "park_num": fields.Integer(),
                "upload": fields.Boolean(),
                "collection_place": fields.String(),
                "follow_user": fields.String(),
                "remarks": fields.String(),
                "car": fields.Integer(),
            },
        )

    def ParyingCollectionListQuerySchemas(self):
        return {
            "page": "页数",
            "per_page": "页容量",
            "create_time": "采集开始时间",
            "update_time": "上传时间",
            "collection_type": "采集类型",
            "city": "采集城市",
            "find_park_time": "开始寻找车位时间",
            "find_park_end_time": "结束寻找车位时间",
            "stop_time": "泊车结束时间",
            "end_time": "采集结束时间",
            "parking_type": "停车场特征",
            "excavate": "是否挖掘",
            "place_type": "车位特征",
            "time_type": "时间特征",
            "othen_type": "其他特征",
            "park_user": "跟车人员",
            "park_num": "泊入车位数量",
            "upload": "是否上传",
            "collection_place": "采集地点",
            "follow_user": "采集人",
            "remarks": "备注",
            "car": "车辆id",
            "car_num": "车号",
            "start_time": "起始时间",
            "over_time": "结束时间",
        }

    def CarInfoSchemas(self):
        return self.ns.model(
            "car_parying_info_body",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def ParyingCollectionImageCreateSchemas(self):
        return self.ns.model(
            "parying_collection_images",
            {
                "id": fields.Integer(),
                "parking_collection_id": fields.Integer(),
                "file": fields.String,
            },
        )

    def ParyingCollectionImageIdSchemas(self):
        return self.ns.model("parying_collection_image_id", {"id": fields.Integer()})

    def ParyingCollectionInfoSchemas(self):
        return self.ns.model(
            "parying_collection_info",
            {
                "id": fields.Integer(),
                "create_time": fields.String(),
                "update_time": fields.String(),
                "collection_type": fields.String(),
                "city": fields.String(),
                "find_park_time": fields.String(),
                "find_park_end_time": fields.String(),
                "stop_time": fields.String(),
                "end_time": fields.String(),
                "parking_type": fields.String(),
                "excavate": fields.Boolean(),
                "place_type": fields.String(),
                "time_type": fields.String(),
                "othen_type": fields.String(),
                "park_user": fields.String(),
                "park_num": fields.Integer(),
                "upload": fields.Boolean(),
                "collection_place": fields.String(),
                "follow_user": fields.String(),
                "remarks": fields.String(),
                "cars": fields.Nested(self.CarInfoSchemas()),
                "images": fields.List(fields.Nested(self.ParyingCollectionImageCreateSchemas())),
            },
        )

    def ParyingCollectionBodySchemas(self):
        return self.ns.model(
            "List_body_parying",
            {
                "total": fields.Integer(),
                "data": fields.List(fields.Nested(self.ParyingCollectionInfoSchemas())),
            },
        )
